package com.heima.behavior.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.apis.behavior.ApUnlikesBehaviorControllerApi;
import com.heima.behavior.service.ApUnlikesBehaviorService;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.behavior.pojos.ApUnlikesBehavior;
import com.heima.model.common.dtos.ResponseResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/v1/unlike_behavior")
public class ApUnlikesBehaviorController implements ApUnlikesBehaviorControllerApi {

    @Autowired
    ApUnlikesBehaviorService apUnlikesBehaviorService;

    @PostMapping
    @Override
    public ResponseResult noLike(@RequestBody UnLikesBehaviorDto dto) {
        return apUnlikesBehaviorService.noLike(dto);
    }

    @GetMapping("/getNoLike")
    public ApUnlikesBehavior getNoLike(@RequestParam("entryID")Integer entryID, @RequestParam("articleID")Long articleID){
        return apUnlikesBehaviorService.getOne(Wrappers.<ApUnlikesBehavior>lambdaQuery().eq(ApUnlikesBehavior::getEntryId,entryID)
        .eq(ApUnlikesBehavior::getArticleId,articleID));
    }
}
